package com.pdh.controller;

import com.pdh.entity.Student;
import com.pdh.mvc.ResponseBody;
import com.pdh.mvc.ResponseView;
import com.pdh.service.StudentService;
import com.pdh.util.JSONUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author: 彭_德华
 * @Date: 2021-09-16 14:14
 */
public class StudentController {
    StudentService service = new StudentService();

    @ResponseView("/toList.do")
    public String toList(HttpServletRequest req, HttpServletResponse resp){
        return "list.html";
    }


    @ResponseBody("/list.do")
    public String list(HttpServletRequest req, HttpServletResponse resp){
        List<Student> list = service.list();
        return JSONUtil.toJSON(list);
    }

}
